//
//  MenuTuiJianChangJingDetailTableViewCell.m
//  Products_B
//
//  Created by lanou on 16/6/2.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "MenuTuiJianChangJingDetailTableViewCell.h"

@implementation MenuTuiJianChangJingDetailTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
         self.picImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 10, 80, 80)];
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 20, 150, 20)];
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 40, kWidth - 110, 30)];
        self.detailLabel.numberOfLines = 0;
        self.detailLabel.textColor = [UIColor grayColor];
        self.detailLabel.font = [UIFont systemFontOfSize:13];
        self.boFangButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.boFangButton.frame = CGRectMake(25, 25, 30, 30);
        [self.boFangButton setBackgroundImage:[UIImage imageNamed:@"menubofang"] forState:(UIControlStateNormal)];
        [self.picImageView addSubview:_boFangButton];
        
        self.myView = [[UIView alloc]initWithFrame:CGRectMake(100, 70, kWidth - 100, 20)];
//        _myView.backgroundColor = [UIColor magentaColor];
        [self.contentView addSubview:_myView];
        [self.contentView addSubview:_picImageView];
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_detailLabel];
    }
    return self;
}
- (void)setModel:(MenuTuiJianChangJingDetailModel *)model{
    _model = model;
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:nil completed:nil];
    self.titleLabel.text = model.dishes_name;
    self.detailLabel.text = model.dishes_desc;
    NSLog(@"%@",model.array);
    
    
if (self.flag == 0) {
    for (int i = 0; i < model.array.count; i++) {
        NSString *string = model.array[i];
        NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:13] forKey:NSFontAttributeName];
        CGRect bounds = [string boundingRectWithSize:CGSizeMake(1000, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
        
        UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
        button.frame = CGRectMake(self.width, 0, bounds.size.width, 20);
        button.titleLabel.font = [UIFont systemFontOfSize:13];
        button.tintColor = [UIColor orangeColor];
        button.layer.cornerRadius = 4;
        button.layer.masksToBounds = YES;
        button.layer.borderWidth = 1;
        button.layer.borderColor = [UIColor orangeColor].CGColor;
        
        [button setTitle:string forState:(UIControlStateNormal)];
        [self.myView addSubview:button];
        self.width += bounds.size.width + 10;
        self.flag = 1;
       }
    }
    self.width = 0;
}
@end
